<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商家数据看板</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <script src="navigation-helper.js"></script>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
        .chart-bar {
            transition: all 0.3s ease;
        }
        .chart-bar:hover {
            transform: scaleY(1.1);
            transform-origin: bottom;
        }
    </style>
</head>
<body class="bg-gray-50">
    <div class="mx-auto max-w-[393px] h-[852px] bg-white relative overflow-hidden rounded-[40px] shadow-2xl">
        <!-- Status Bar -->
        <div class="bg-white px-6 pt-3 pb-2">
            <div class="flex justify-between items-center text-xs">
                <span class="font-semibold">9:41</span>
                <div class="flex space-x-1">
                    <i class="fas fa-signal"></i>
                    <i class="fas fa-wifi"></i>
                    <i class="fas fa-battery-full"></i>
                </div>
            </div>
        </div>

        <!-- Header -->
        <div class="bg-gradient-to-r from-indigo-600 to-purple-600 px-4 py-3">
            <div class="flex items-center justify-between text-white mb-2">
                <i class="fas fa-arrow-left text-lg"></i>
                <h1 class="text-lg font-semibold">数据看板</h1>
                <i class="fas fa-download text-lg"></i>
            </div>
            
            <!-- Date Selector -->
            <div class="bg-white/10 backdrop-blur-sm rounded-lg p-3">
                <div class="flex items-center justify-between mb-2">
                    <span id="current-date" class="text-white/90 text-sm font-medium">2025年1月5日</span>
                    <button onclick="toggleDatePicker()" class="text-white/80 hover:text-white transition-colors">
                        <i class="fas fa-calendar-alt"></i>
                    </button>
                </div>
                <div class="flex space-x-2">
                    <button onclick="selectDateRange('today')" id="today-btn" class="date-range-btn bg-white/20 text-white px-2 py-1 rounded text-xs">今日</button>
                    <button onclick="selectDateRange('week')" id="week-btn" class="date-range-btn bg-white text-indigo-600 px-2 py-1 rounded text-xs font-medium">近7天</button>
                    <button onclick="selectDateRange('month')" id="month-btn" class="date-range-btn bg-white/20 text-white px-2 py-1 rounded text-xs">本月</button>
                    <button onclick="selectDateRange('quarter')" id="quarter-btn" class="date-range-btn bg-white/20 text-white px-2 py-1 rounded text-xs">本季</button>
                </div>
            </div>
        </div>

        <!-- Scrollable Content -->
        <div class="h-[calc(852px-120px)] overflow-y-auto pb-32">
            <!-- Today's Overview -->
            <div class="p-4">
                <h3 class="font-bold text-gray-800 mb-3 flex items-center">
                    <span class="w-1 h-4 bg-indigo-600 mr-2 rounded-full"></span>
                    今日实时数据
                </h3>
                <div class="grid grid-cols-2 gap-3">
                    <div class="bg-gradient-to-br from-blue-500 to-blue-600 rounded-xl p-4 text-white min-h-[120px] flex flex-col justify-between">
                        <div class="flex items-start justify-between">
                            <div class="flex-1">
                                <p class="text-xs opacity-90 mb-1">销售额</p>
                                <p class="text-xl font-bold leading-tight">¥28,586</p>
                            </div>
                            <i class="fas fa-money-bill-wave text-lg opacity-70 ml-2"></i>
                        </div>
                        <div class="flex items-center text-xs mt-2">
                            <i class="fas fa-arrow-up mr-1 text-xs"></i>
                            <span>12.5%</span>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-green-500 to-green-600 rounded-xl p-4 text-white min-h-[120px] flex flex-col justify-between">
                        <div class="flex items-start justify-between">
                            <div class="flex-1">
                                <p class="text-xs opacity-90 mb-1">订单数</p>
                                <p class="text-xl font-bold leading-tight">186</p>
                            </div>
                            <i class="fas fa-shopping-bag text-lg opacity-70 ml-2"></i>
                        </div>
                        <div class="flex items-center text-xs mt-2">
                            <i class="fas fa-arrow-up mr-1 text-xs"></i>
                            <span>8.3%</span>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-purple-500 to-purple-600 rounded-xl p-4 text-white min-h-[120px] flex flex-col justify-between">
                        <div class="flex items-start justify-between">
                            <div class="flex-1">
                                <p class="text-xs opacity-90 mb-1">访客数</p>
                                <p class="text-xl font-bold leading-tight">1,258</p>
                            </div>
                            <i class="fas fa-users text-lg opacity-70 ml-2"></i>
                        </div>
                        <div class="flex items-center text-xs mt-2">
                            <i class="fas fa-arrow-up mr-1 text-xs"></i>
                            <span>15.6%</span>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-orange-500 to-orange-600 rounded-xl p-4 text-white min-h-[120px] flex flex-col justify-between">
                        <div class="flex items-start justify-between">
                            <div class="flex-1">
                                <p class="text-xs opacity-90 mb-1">转化率</p>
                                <p class="text-xl font-bold leading-tight">14.8%</p>
                            </div>
                            <i class="fas fa-percentage text-lg opacity-70 ml-2"></i>
                        </div>
                        <div class="flex items-center text-xs mt-2">
                            <i class="fas fa-arrow-up mr-1 text-xs"></i>
                            <span>2.1%</span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Sales Trend -->
            <div class="p-4">
                <h3 class="font-bold text-gray-800 mb-3 flex items-center justify-between">
                    <span class="flex items-center">
                        <span class="w-1 h-4 bg-indigo-600 mr-2 rounded-full"></span>
                        销售趋势
                    </span>
                    <div class="flex items-center space-x-2">
                        <select id="chart-type" class="text-xs bg-gray-100 rounded px-2 py-1 border-0" onchange="updateChartType()">
                            <option value="sales">销售额</option>
                            <option value="orders">订单数</option>
                            <option value="visitors">访客数</option>
                            <option value="conversion">转化率</option>
                        </select>
                        <button onclick="refreshChart()" class="text-gray-500 hover:text-indigo-600 text-xs">
                            <i class="fas fa-sync-alt"></i>
                        </button>
                    </div>
                </h3>
                <div class="bg-gray-50 rounded-xl p-4">
                    <div class="h-40 flex items-end justify-between space-x-2">
                        <div class="flex-1 chart-bar bg-gradient-to-t from-indigo-500 to-indigo-300 rounded-t" style="height: 60%"></div>
                        <div class="flex-1 chart-bar bg-gradient-to-t from-indigo-500 to-indigo-300 rounded-t" style="height: 80%"></div>
                        <div class="flex-1 chart-bar bg-gradient-to-t from-indigo-500 to-indigo-300 rounded-t" style="height: 45%"></div>
                        <div class="flex-1 chart-bar bg-gradient-to-t from-indigo-500 to-indigo-300 rounded-t" style="height: 90%"></div>
                        <div class="flex-1 chart-bar bg-gradient-to-t from-purple-500 to-purple-300 rounded-t" style="height: 100%"></div>
                        <div class="flex-1 chart-bar bg-gradient-to-t from-indigo-500 to-indigo-300 rounded-t" style="height: 70%"></div>
                        <div class="flex-1 chart-bar bg-gradient-to-t from-indigo-500 to-indigo-300 rounded-t" style="height: 85%"></div>
                    </div>
                    <div class="flex justify-between text-xs text-gray-500 mt-2">
                        <span>一</span>
                        <span>二</span>
                        <span>三</span>
                        <span>四</span>
                        <span>五</span>
                        <span>六</span>
                        <span>日</span>
                    </div>
                </div>
            </div>

            <!-- Top Products -->
            <div class="p-4">
                <h3 class="font-bold text-gray-800 mb-3 flex items-center justify-between">
                    <span class="flex items-center">
                        <span class="w-1 h-4 bg-indigo-600 mr-2 rounded-full"></span>
                        热销TOP5
                    </span>
                    <button onclick="viewAllBestSellers()" class="text-xs text-indigo-600 hover:text-indigo-800 transition-colors">查看全部 <i class="fas fa-chevron-right text-xs"></i></button>
                </h3>
                <div class="space-y-3">
                    <div class="flex items-center bg-white rounded-lg border border-gray-200 p-3">
                        <span class="w-8 h-8 bg-gradient-to-br from-yellow-400 to-orange-400 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">1</span>
                        <img src="https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=40&h=40&fit=crop" alt="" class="w-10 h-10 rounded-lg object-cover mr-3">
                        <div class="flex-1">
                            <p class="text-sm font-medium">无线蓝牙耳机</p>
                            <p class="text-xs text-gray-500">销量: 86件</p>
                        </div>
                        <p class="text-sm font-bold text-indigo-600">¥299</p>
                    </div>
                    
                    <div class="flex items-center bg-white rounded-lg border border-gray-200 p-3">
                        <span class="w-8 h-8 bg-gradient-to-br from-gray-400 to-gray-500 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">2</span>
                        <img src="https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=40&h=40&fit=crop" alt="" class="w-10 h-10 rounded-lg object-cover mr-3">
                        <div class="flex-1">
                            <p class="text-sm font-medium">智能手表</p>
                            <p class="text-xs text-gray-500">销量: 52件</p>
                        </div>
                        <p class="text-sm font-bold text-indigo-600">¥1299</p>
                    </div>
                    
                    <div class="flex items-center bg-white rounded-lg border border-gray-200 p-3">
                        <span class="w-8 h-8 bg-gradient-to-br from-orange-400 to-orange-500 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">3</span>
                        <img src="https://images.unsplash.com/photo-1484704849700-f032a568e944?w=40&h=40&fit=crop" alt="" class="w-10 h-10 rounded-lg object-cover mr-3">
                        <div class="flex-1">
                            <p class="text-sm font-medium">便携充电宝</p>
                            <p class="text-xs text-gray-500">销量: 41件</p>
                        </div>
                        <p class="text-sm font-bold text-indigo-600">¥89</p>
                    </div>
                </div>
            </div>

            <!-- Traffic Sources -->
            <div class="p-4">
                <h3 class="font-bold text-gray-800 mb-3 flex items-center">
                    <span class="w-1 h-4 bg-indigo-600 mr-2 rounded-full"></span>
                    流量来源
                </h3>
                <div class="space-y-2">
                    <div class="bg-gray-50 rounded-lg p-3">
                        <div class="flex justify-between items-center mb-2">
                            <span class="text-sm font-medium">搜索流量</span>
                            <span class="text-sm font-bold text-indigo-600">42%</span>
                        </div>
                        <div class="bg-gray-200 rounded-full h-2">
                            <div class="bg-gradient-to-r from-indigo-500 to-purple-500 h-2 rounded-full" style="width: 42%"></div>
                        </div>
                    </div>
                    
                    <div class="bg-gray-50 rounded-lg p-3">
                        <div class="flex justify-between items-center mb-2">
                            <span class="text-sm font-medium">推荐流量</span>
                            <span class="text-sm font-bold text-green-600">28%</span>
                        </div>
                        <div class="bg-gray-200 rounded-full h-2">
                            <div class="bg-gradient-to-r from-green-500 to-emerald-500 h-2 rounded-full" style="width: 28%"></div>
                        </div>
                    </div>
                    
                    <div class="bg-gray-50 rounded-lg p-3">
                        <div class="flex justify-between items-center mb-2">
                            <span class="text-sm font-medium">直接访问</span>
                            <span class="text-sm font-bold text-blue-600">18%</span>
                        </div>
                        <div class="bg-gray-200 rounded-full h-2">
                            <div class="bg-gradient-to-r from-blue-500 to-cyan-500 h-2 rounded-full" style="width: 18%"></div>
                        </div>
                    </div>
                    
                    <div class="bg-gray-50 rounded-lg p-3">
                        <div class="flex justify-between items-center mb-2">
                            <span class="text-sm font-medium">活动流量</span>
                            <span class="text-sm font-bold text-orange-600">12%</span>
                        </div>
                        <div class="bg-gray-200 rounded-full h-2">
                            <div class="bg-gradient-to-r from-orange-500 to-red-500 h-2 rounded-full" style="width: 12%"></div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- User Analysis -->
            <div class="p-4 pb-8">
                <h3 class="font-bold text-gray-800 mb-3 flex items-center">
                    <span class="w-1 h-4 bg-indigo-600 mr-2 rounded-full"></span>
                    用户分析
                </h3>
                <div class="grid grid-cols-2 gap-3">
                    <div class="bg-gradient-to-br from-indigo-50 to-purple-50 rounded-lg p-3 border border-indigo-100">
                        <p class="text-xs text-gray-600 mb-1">复购率</p>
                        <p class="text-xl font-bold text-indigo-600">32.5%</p>
                        <div class="mt-1 flex items-center text-xs text-green-600">
                            <i class="fas fa-arrow-up mr-1"></i>
                            <span>+3.2%</span>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-green-50 to-emerald-50 rounded-lg p-3 border border-green-100">
                        <p class="text-xs text-gray-600 mb-1">客单价</p>
                        <p class="text-xl font-bold text-green-600">¥153.7</p>
                        <div class="mt-1 flex items-center text-xs text-green-600">
                            <i class="fas fa-arrow-up mr-1"></i>
                            <span>+5.8%</span>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-purple-50 to-pink-50 rounded-lg p-3 border border-purple-100">
                        <p class="text-xs text-gray-600 mb-1">新客占比</p>
                        <p class="text-xl font-bold text-purple-600">45.2%</p>
                        <div class="mt-1 flex items-center text-xs text-red-600">
                            <i class="fas fa-arrow-down mr-1"></i>
                            <span>-2.1%</span>
                        </div>
                    </div>
                    
                    <div class="bg-gradient-to-br from-orange-50 to-red-50 rounded-lg p-3 border border-orange-100">
                        <p class="text-xs text-gray-600 mb-1">会员占比</p>
                        <p class="text-xl font-bold text-orange-600">68.3%</p>
                        <div class="mt-1 flex items-center text-xs text-green-600">
                            <i class="fas fa-arrow-up mr-1"></i>
                            <span>+7.2%</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Custom Date Picker Modal -->
        <div id="date-picker-modal" class="fixed inset-0 bg-black/50 hidden z-50" onclick="closeDatePicker()">
            <div class="absolute bottom-0 left-0 right-0 bg-white rounded-t-3xl p-4 mx-4 mb-4" onclick="event.stopPropagation()">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="text-lg font-semibold">选择日期范围</h3>
                    <button onclick="closeDatePicker()" class="text-gray-500 hover:text-gray-700">
                        <i class="fas fa-times text-lg"></i>
                    </button>
                </div>
                
                <div class="grid grid-cols-2 gap-4 mb-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-2">开始日期</label>
                        <input type="date" id="start-date" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-2">结束日期</label>
                        <input type="date" id="end-date" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent">
                    </div>
                </div>
                
                <div class="grid grid-cols-2 gap-3 mb-4">
                    <button onclick="setQuickDate('yesterday')" class="bg-gray-100 text-gray-700 py-2 px-3 rounded-lg text-sm hover:bg-gray-200">昨天</button>
                    <button onclick="setQuickDate('last3days')" class="bg-gray-100 text-gray-700 py-2 px-3 rounded-lg text-sm hover:bg-gray-200">最近3天</button>
                    <button onclick="setQuickDate('lastweek')" class="bg-gray-100 text-gray-700 py-2 px-3 rounded-lg text-sm hover:bg-gray-200">上周</button>
                    <button onclick="setQuickDate('lastmonth')" class="bg-gray-100 text-gray-700 py-2 px-3 rounded-lg text-sm hover:bg-gray-200">上月</button>
                </div>
                
                <div class="flex space-x-3">
                    <button onclick="closeDatePicker()" class="flex-1 bg-gray-100 text-gray-700 py-3 rounded-lg font-medium">取消</button>
                    <button onclick="applyDateRange()" class="flex-1 bg-indigo-600 text-white py-3 rounded-lg font-medium">确定</button>
                </div>
            </div>
        </div>

        <!-- Bottom Navigation -->
        <div class="absolute bottom-0 left-0 right-0 bg-white border-t border-gray-200">
            <div class="flex justify-around py-2" id="bottom-nav">
                <a href="home-b2c.html" class="flex-1 text-center py-2">
                    <i class="fas fa-home text-xl text-gray-400 mb-1"></i>
                    <p class="text-xs text-gray-400">首页</p>
                </a>
                <a href="b2b-dashboard.html" class="flex-1 text-center py-2">
                    <i class="fas fa-chart-bar text-xl text-indigo-600 mb-1"></i>
                    <p class="text-xs text-indigo-600">数据</p>
                </a>
                <a href="b2b-profile.html" class="flex-1 text-center py-2">
                    <i class="fas fa-user text-xl text-gray-400 mb-1"></i>
                    <p class="text-xs text-gray-400">我的</p>
                </a>
            </div>
        </div>
    </div>

    <script>
        let currentDateRange = 'week';
        let currentChartType = 'sales';

        // 日期范围选择
        function selectDateRange(range) {
            currentDateRange = range;
            
            // 更新按钮状态
            document.querySelectorAll('.date-range-btn').forEach(btn => {
                btn.classList.remove('bg-white', 'text-indigo-600', 'font-medium');
                btn.classList.add('bg-white/20', 'text-white');
            });
            
            document.getElementById(range + '-btn').classList.remove('bg-white/20', 'text-white');
            document.getElementById(range + '-btn').classList.add('bg-white', 'text-indigo-600', 'font-medium');
            
            // 更新数据
            updateDateDisplay(range);
            updateDashboardData(range);
            updateChart(range, currentChartType);
        }

        // 更新日期显示
        function updateDateDisplay(range) {
            const today = new Date();
            let dateText = '';
            
            switch(range) {
                case 'today':
                    dateText = formatDate(today);
                    break;
                case 'week':
                    const weekStart = new Date(today.getTime() - 6 * 24 * 60 * 60 * 1000);
                    dateText = formatDate(weekStart) + ' - ' + formatDate(today);
                    break;
                case 'month':
                    dateText = today.getFullYear() + '年' + (today.getMonth() + 1) + '月';
                    break;
                case 'quarter':
                    const quarter = Math.floor(today.getMonth() / 3) + 1;
                    dateText = today.getFullYear() + '年第' + quarter + '季度';
                    break;
            }
            
            document.getElementById('current-date').textContent = dateText;
        }

        // 格式化日期
        function formatDate(date) {
            return date.getFullYear() + '年' + (date.getMonth() + 1) + '月' + date.getDate() + '日';
        }

        // 更新仪表板数据
        function updateDashboardData(range) {
            const dataSets = {
                today: {
                    sales: '¥8,580', orders: '86', visitors: '1,258', conversion: '14.8%'
                },
                week: {
                    sales: '¥128,580', orders: '2,386', visitors: '18,256', conversion: '13.1%'
                },
                month: {
                    sales: '¥586,240', orders: '8,965', visitors: '125,680', conversion: '14.2%'
                },
                quarter: {
                    sales: '¥1,856,420', orders: '28,756', visitors: '386,240', conversion: '13.8%'
                }
            };

            const data = dataSets[range] || dataSets.week;
            
            // 更新概览卡片数据
            const cards = document.querySelectorAll('.bg-gradient-to-br');
            if (cards.length >= 4) {
				  const salesEl = cards[0].querySelector('.text-xl');
                  const ordersEl = cards[1].querySelector('.text-xl');
                  const visitorsEl = cards[2].querySelector('.text-xl');
                  const conversionEl = cards[3].querySelector('.text-xl');

                  if (salesEl) salesEl.textContent = data.sales;
                  if (ordersEl) ordersEl.textContent = data.orders;
                  if (visitorsEl) visitorsEl.textContent = data.visitors;
                  if (conversionEl) conversionEl.textContent = data.conversion;
				
            }
        }

        // 更新图表类型
        function updateChartType() {
            currentChartType = document.getElementById('chart-type').value;
            updateChart(currentDateRange, currentChartType);
        }

        // 更新图表
        function updateChart(range, type) {
            const bars = document.querySelectorAll('.chart-bar');
            const chartData = {
                sales: ['60%', '80%', '45%', '90%', '100%', '70%', '85%'],
                orders: ['75%', '65%', '85%', '70%', '95%', '80%', '75%'],
                visitors: ['55%', '75%', '65%', '85%', '90%', '75%', '80%'],
                conversion: ['40%', '60%', '50%', '75%', '65%', '55%', '70%']
            };
            
            const heights = chartData[type] || chartData.sales;
            
            bars.forEach((bar, index) => {
                if (index < heights.length) {
                    bar.style.height = heights[index];
                }
            });
        }

        // 刷新图表
        function refreshChart() {
            const refreshBtn = document.querySelector('button[onclick="refreshChart()"] i');
            refreshBtn.classList.add('fa-spin');
            
            setTimeout(() => {
                refreshBtn.classList.remove('fa-spin');
                updateChart(currentDateRange, currentChartType);
            }, 1000);
        }

        // 打开日期选择器
        function toggleDatePicker() {
            const modal = document.getElementById('date-picker-modal');
            if (modal.classList.contains('hidden')) {
                modal.classList.remove('hidden');
                
                // 设置默认日期
                const today = new Date();
                const weekAgo = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000);
                
                document.getElementById('end-date').value = today.toISOString().split('T')[0];
                document.getElementById('start-date').value = weekAgo.toISOString().split('T')[0];
            } else {
                modal.classList.add('hidden');
            }
        }

        // 关闭日期选择器
        function closeDatePicker() {
            document.getElementById('date-picker-modal').classList.add('hidden');
        }

        // 设置快速日期
        function setQuickDate(period) {
            const today = new Date();
            let startDate, endDate = today;
            
            switch(period) {
                case 'yesterday':
                    startDate = new Date(today.getTime() - 24 * 60 * 60 * 1000);
                    endDate = startDate;
                    break;
                case 'last3days':
                    startDate = new Date(today.getTime() - 3 * 24 * 60 * 60 * 1000);
                    break;
                case 'lastweek':
                    startDate = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000);
                    endDate = new Date(today.getTime() - 1 * 24 * 60 * 60 * 1000);
                    break;
                case 'lastmonth':
                    startDate = new Date(today.getFullYear(), today.getMonth() - 1, 1);
                    endDate = new Date(today.getFullYear(), today.getMonth(), 0);
                    break;
            }
            
            document.getElementById('start-date').value = startDate.toISOString().split('T')[0];
            document.getElementById('end-date').value = endDate.toISOString().split('T')[0];
        }

        // 应用日期范围
        function applyDateRange() {
            const startDate = document.getElementById('start-date').value;
            const endDate = document.getElementById('end-date').value;
            
            if (!startDate || !endDate) {
                alert('请选择开始和结束日期');
                return;
            }
            
            if (new Date(startDate) > new Date(endDate)) {
                alert('开始日期不能大于结束日期');
                return;
            }
            
            // 更新显示
            const start = new Date(startDate);
            const end = new Date(endDate);
            const customDateText = formatDate(start) + ' - ' + formatDate(end);
            
            document.getElementById('current-date').textContent = customDateText;
            
            // 重置按钮状态
            document.querySelectorAll('.date-range-btn').forEach(btn => {
                btn.classList.remove('bg-white', 'text-indigo-600', 'font-medium');
                btn.classList.add('bg-white/20', 'text-white');
            });
            
            // 更新数据（这里可以添加API调用）
            updateDashboardData('custom');
            closeDatePicker();
        }

        // 查看全部热销商品
        function viewAllBestSellers() {
            window.location.href = 'best-sellers.html';
        }

        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            selectDateRange('week'); // 默认选择近7天
            updateBottomNavigation(); // Update navigation based on login status
        });
    </script>
</body>
</html>